<?php
header("Content-Type: text/html;charset=utf-8");
include('Includes/DB.inc.php');
include('Includes/AC.inc.php');
?>
<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<title> 菜单排序 </title>
	<style>
		h6 {font-size:16px;margin:10px;}
		li {margin:10px 0;}
		input[type=text] {width:20px;text-align:center;}
		.msg {font-size:13px;margin:3px 10px;}

		#postUserMenuSort {
			float:left;
			margin-right:100px;
		}

		#getUserMenuSort {
			float:left;
		}
	</style>

	<script src="js/jquery.js"></script>
	<script>
	$(document).ready(function(){
		$("form").submit(function(e) {
			$.post(
				'_dev.php',
				$('form').serialize(),
				function(data,status) {
					//alert("Data: " + data + "\nStatus: " + status);
					//alert(data);
					$("#postUserMenuSort .msg").html(data);
					getUserMenuSort();
				}
			);
			return false;
		});

		//获取用户菜单排序
		getUserMenuSort = function() {
			$.post(
				'_dev.php',
				{status:'getUserMenuSort'},
				function(data,status) {
					$("#getUserMenuSort pre").html(data);
				}
			);
		}
		$("#getUserMenuSort button").click(function(e) {
			getUserMenuSort();
			return false;
		});




	});
	</script>
</head>
<body>

<div id="postUserMenuSort">
	<form method="post">
		<?php 
			$dbh = db::connect();
			foreach(ac::buildUserMenu('1', $dbh, DBTP) as $app => $appRes) { 
		?>

			<div style="margin:20px 0;">
				<h6><?=$appRes['name']?> (<?=$app?>) <input type="text" name="sort[<?=$app?>][sort]" value="0"></h6>
				<div style="margin-left:30px;">
					<ul>
					<?php foreach($appRes['funs'] as $fun => $funName) { ?>
						<li>
							<span><?=$funName?> (<?=$fun?>) <input type="text" name="sort[<?=$app?>][funs][<?=$fun?>]" value="0"></span>
						</li>
					<?php } ?>
					</ul>
				</div>
			</div>

		<?php } ?>
		
		<input type='hidden' name='status' value="postUserMenuSort">
		<input type="submit" value="提交">
		<span class="msg"></span>
	</form>
</div>



<div id="getUserMenuSort">
	<button>读取</button>
	<pre></pre>
</div>


</body>
</html>